package org.example.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private String msg;
    private int code;
    private T data;

    public Result(T data) {
        this.data = data;
    }
    public static <T>Result<T> success(T data) {
        Result<T> result = new Result<>(data);
        result.setCode(200);
        result.setMsg("success");
        return result;
    }


    public static Result success() {
        Result result = new Result<>();
        result.setCode(200);
        result.setMsg("success");
        return result;
    }

    public static Result error(String msg) {
        return new Result(msg, 1, null);
    }
}
